package com.example.geomanager;

import android.content.Context;
import android.location.Criteria;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

public class MainActivity extends MapActivity {
	
	public static final String TAG = "MapActivity";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);
        
        // Acquire a reference to the system Location Manager
        LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

        // Define a listener that responds to location updates
        LocationListener locationListener = new MapLocationListener(mapView, this);
        
        // Find the best location provider we can get.
        Criteria criteria = new Criteria();
  		criteria.setAccuracy(Criteria.ACCURACY_COARSE);
  		String provider = locationManager.getBestProvider(criteria, true);
  		
  		if ( provider == null ) {
  			Log.e(TAG, "No location provider found!");
  			return;
  		}

        // Register the listener with the Location Manager to receive location updates
        locationManager.requestLocationUpdates(provider, 10, 0, locationListener);
    }

	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}
}
